package com.example.qxfw.qxxx.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.qx.Doppler;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.util.List;

@Mapper
@DS("qx")
public interface DopplerMapper extends BaseMapper<Doppler> {
    @Select("select datechar, timechar " +
            "from doppler " +
            "order by datechar,timechar desc")
    List<Doppler> selectMaxTime();

    @Select("select * " +
            "from doppler " +
            "where datechar ='${dateChar}' and TimeChar between '${timeChar1}' and '${timeChar2}' and ldtype='${idType}' and elevation='${elevation}' " +
            "order by datechar,timechar desc")
    List<Doppler> selectList(String dateChar, String timeChar1, String timeChar2, String stationId, String idType, String elevation);

    @Select("select * " +
            "from doppler " +
            "where (datechar ='${dateChar1}' and TimeChar>='${timeChar1}') or (datechar ='${dateChar2}' and TimeChar>='${timeChar2}') or (datechar >'${dateChar1}' and ldtype='${idType}' and elevation='${elevation}' ) and ldtype='${idType}' " +
            "order by datechar,timechar desc")
    List<Doppler> selectLists(String dateChar1, String timeChar1, String dateChar2, String timeChar2, String stationId, String idType, String elevation);

    @Select("select datayear, datechar, trim(timechar) as timechar, trim(stationid) as stationid, trim(ldtype) as ldtype, elevation, path, lbimgpath, jwimgpath, radtitle, serverpath, state, west, south, east, north, warning, fwest, fsouth, feast, fnorth " +
            "from doppler")
    List<Doppler> selectDoppler();

    @Select("select datayear, datechar, trim(timechar) as timechar, trim(stationid) as stationid, trim(ldtype) as ldtype, elevation, path, lbimgpath, jwimgpath, radtitle, serverpath, state, west, south, east, north, warning, fwest, fsouth, feast, fnorth " +
            "from doppler where datechar between #{dateCharStart} and #{dateCharEnd} and ldtype = #{ldType} and elevation = #{elevation}")
    List<Doppler> selectDopplerByDateCharLdTypeAndElevation(@Param("dateCharStart") Timestamp dateCharStart, @Param("dateCharEnd") Timestamp dateCharEnd, @Param("ldType") String ldType, @Param("elevation") float elevation);

    @Select("select datayear, datechar, trim(timechar) as timechar, trim(stationid) as stationid, trim(ldtype) as ldtype, elevation, path, lbimgpath, jwimgpath, radtitle, serverpath, state, west, south, east, north, warning, fwest, fsouth, feast, fnorth " +
            "from doppler where path = #{path}")
    List<Doppler> selectDopplerByPath(String path);
}
